<?php require_once('../Connections/locale.php'); ?>
<?php
mysql_select_db($database_locale, $locale);
$query_apikey = "SELECT gmapsapi FROM siteoptions WHERE sitename = 'Gestione_Abbonamenti'";
$apikey = mysql_query($query_apikey, $locale) or die(mysql_error());
$row_apikey = mysql_fetch_assoc($apikey);
$totalRows_apikey = mysql_num_rows($apikey);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Localizzazione</title>

<script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo $row_apikey['gmapsapi']; ?>" type="text/javascript"></script>

<script language="JavaScript" type="text/javascript">
    var map;

     

    function map_create(elemento) {
    map=new GMap2(document.getElementById(elemento));
    map.setCenter(new GLatLng(41.895466,12.482323),10,G_NORMAL_MAP);
    map.addControl(new GMapTypeControl());
    map.addControl(new GLargeMapControl());
    mapmade=true;
    }
	
	
	
	function AddMarkerFromAddress(address, fumetto, titolo) { 
	  
	  var geocoder = new GClientGeocoder();
	  geocoder.getLatLng(
	    address,
	    function(point) {
	      if (!point) {
	        //alert(address + " not found");
	      } else {
	        //map.setCenter(point, 13);
	        
	        	var icon1 = new GIcon(); 
				icon1.image = "../images/green.png"; 
				icon1.iconSize = new GSize(33, 36);
				icon1.iconAnchor = new GPoint(10,30); 
				icon1.infoWindowAnchor = new GPoint(12, 3);
	        
	        //var marker = new GMarker(point);
	        var marker = new PdMarker(point, icon1);
	        GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(fumetto);
			});
			marker.setTooltip(titolo);
	        map.addOverlay(marker);	        
	        //marker.openInfoWindowHtml(address);
			
	      }
	    }
	  );
	  
}
	
	
	/*
	function AddMarkerFromAddress(address, fumetto, titolo) {

    var geocoder = new GClientGeocoder();
    geocoder.getLatLng(address,
    	function(point) {
    		if (!point) {
    			alert(address + " non trovato!");
    		} else {
    			var marker = new GMarker(point);
    			GEvent.addListener(marker, "click", function() {
    				marker.openInfoWindowHtml(fumetto);
    			});
    			map.addOverlay(marker);
    			}
    		}
    	);

    }
	*/
	
	function AddMarkerFromAddressAndPoint(address, fumetto, titolo) { 
	  
	  var geocoder = new GClientGeocoder();
	  geocoder.getLatLng(
	    address,
	    function(point) {
	      if (!point) {
	        alert("Indirizzo non trovato!");
	      } else {
	      
	        
	        var marker = new GMarker(point);
	        //var marker = new PdMarker(point, icon1);
	        GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(fumetto);
			});
			//marker.setTooltip(titolo);
	        map.addOverlay(marker);	        
	        marker.openInfoWindowHtml(fumetto);
			map.setCenter(point, 13);
	      }
	    }
	  );
	  
}
	
	
	function LoadPage(nominativo,indirizzo) {
		map_create("mappa");
		var testo = "<strong>"+nominativo+"</strong><br>"+indirizzo;	
		AddMarkerFromAddressAndPoint(indirizzo, testo, nominativo);	
	}
	
	
</script>


</head>

<body onload="LoadPage('<?php echo $_GET[nominativo]; ?>','<?php echo $_GET[indirizzo]; ?>')">
<div id="mappa" style="width: 500px; height: 300px"></div>

</body>
</html>
<?php
mysql_free_result($apikey);
?>
